<!DOCTYPE html>
<html>
{% include head.html %}
<body>

{% include sidebar.html %}

<div class="wrapper">
    {{ content }}
</div>


<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
        crossorigin="anonymous"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script type="text/javascript">

    function link(id) {
        return '<a class="anchor" href="#' + id + '" id="' + id + '">link</a>'
    }

    function textToHref(el) {
        return $(el).text().trim().toLocaleLowerCase().replace(/\W/g, '-')
    }

    $(document).ready(function() {

        // Configuration for syntax highlighting using highlightjs.org
        hljs.configure({
            classPrefix: ''
        });

        // Code highlight
        $('pre code').each(function(i, block) {
            hljs.highlightBlock(block);
        });

        // Adding anchors to headers
        $('h1,h2,h3,h4,h5,h6', '.doc-full').each(function(i, header) {
            $(header).append(link(textToHref(header)));
        });

        // Adding anchors to api
        $('.endpoint,.definition').each(function(i, container) {
            var el = $(container);
            var href = el.data('href');
            el.find('.title').append(link(href));
            el.find('.param-name').each(function(i, td) {
                var hrefParam = href + '*' + textToHref(td);
                $(td).append(link(hrefParam));
            });
        });

        // Simple jquery tabs for api response
        $('.tabs').each(function(i, tabs) {
            var links = $(tabs).find('li');
            links.first().toggleClass('tab__link--active');

            links.click(function() {
                var target = $(this).attr('data-href');
                links.removeClass('tab__link--active');
                $(this).addClass('tab__link--active');

                $(tabs).find('.tab__content').hide();
                $(tabs).find('[data-id="' + target + '"]').show();
            });
        });
    });
</script>
</body>
</html>
